package com.bodu.system.service.impl;

import com.bodu.core.entity.ParamReq;
import com.bodu.system.entity.po.AreaPo;
import com.bodu.system.entity.request.AreaRequest;
import com.bodu.system.entity.vo.AreaVo;
import com.bodu.system.mapper.AreaMapper;
import com.bodu.system.service.AreaService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Administrator
 */
@Service("areaService")
public class AreaServiceImpl implements AreaService {

    @Resource
    private AreaMapper areaMapper;

    @Override
    public AreaVo getModel(Long id) {
        AreaPo areaPo = areaMapper.getModel(id);
        AreaVo areaVo = new AreaVo();
        BeanUtils.copyProperties(areaPo, areaVo);
        return areaVo;
    }

    @Override
    public Long save(AreaRequest request) {
        areaMapper.save(request);
        return request.getId();
    }

    @Override
    public Long update(AreaRequest request) {
        areaMapper.update(request);
        return request.getId();
    }

    @Override
    public List<AreaVo> listPage(ParamReq<AreaRequest> params) {
        return null;
    }

    @Override
    public Integer countPage(ParamReq<AreaRequest> params) {
        return null;
    }

    @Override
    public Integer updateDelFlagById(Long id, Integer delFlag) {
        return null;
    }

    @Override
    public List<AreaPo> findAreaByParentCode(Long parentCode) {
        return areaMapper.findAreaByParentCode(parentCode);
    }
}
